interface detType{
    img:string,
    title:string,
    desc:string,
    id:string,
    num:number,
}
interface itemType{
    code:number,
    data1:detType
}
const lis=location.href.split("?")
// console.log(lis)
let id=(lis[1].slice(3))
// console.log(id)
Ajax(`/api/detail?id=${id}`,(data:itemType)=>{

  Detailrender(data.data1)
})

const Detailrender=(data1:detType)=>{
    // console.log(data1)
    const detail:Element|null=document.querySelector('.detail');
     (detail as Element).innerHTML=`
     <dl>
        <dt>
            <img src="${data1.img}" alt='' />
        </dt>
        <dd>
        <p><b>${data1.title}</b></p>
        <h3>￥${data1.num}</h3>
        <p>${data1.desc}</p>
      
        </dd>
     </dl>
     <span>
     <button class="rem">返回上一页</button>
     <button class="add">点击购买</button>
     </span>
     `
     Button()
}

const Button=()=>{
    const rem:Element|null=document.querySelector('.rem');
    rem?.addEventListener('click',e=>{
        location.href='/index.html'
    })
    const add:Element|null=document.querySelector('.add');
    add?.addEventListener('click',e=>{
        location.href='/num.html'
    })
}